package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Goods;
import com.yidiandao.business.ui.goodsdetail.GoodsDetailActivity;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.BuyGoodsHolder;
import com.yidiandao.business.utils.ImageLoader;
import com.yidiandao.business.utils.TextRenderUtils;
import com.yidiandao.business.utils.UIUtils;

/** 确认订单-商品清单-购买商品-ListItem */
public class BuyGoodsListItem
        extends DisplayListItem<BuyGoodsHolder, Goods> {

    public BuyGoodsListItem(Goods s) {
        super(s);
    }

    @Override
    public void onShow(final Context context, BuyGoodsHolder holder) {
        ImageLoader.loadImageWithPlaceHolder(context, holder.ivGoodsImage, data.getGoodsThumb());
        holder.tvPrice.setText(
                TextRenderUtils.getBeautyPrice(
                        data.getGoodsPrice() + "", null, UIUtils.dp2px(16), UIUtils.dp2px(13)));
        holder.tvCount.setText(UIUtils.getString(R.string.goods_count, data.getGoodsNumber()));
        holder.tvTitle.setText(data.getGoodsName());

        holder.rootLayout.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        GoodsDetailActivity.actionStart((Activity) context, data.getGoodsId());
                    }
                });
    }

    @Override
    public String getDisplayItemTag() {
        return BuyGoodsListItem.class.getSimpleName();
    }

    @Override
    public Class<BuyGoodsHolder> getViewHolderClazz() {
        return BuyGoodsHolder.class;
    }
}
